package com.googlecode.moneyManager.model;

import javax.persistence.Id;
import javax.persistence.MappedSuperclass;
/**
 * 
 * @author Sergiy Doroshenko
 * Jul 15, 2008 1:15:11 AM
 */
@MappedSuperclass
public abstract class BaseEntity implements java.io.Serializable {
    
    private String id; // Could be a numeric type...

    public BaseEntity() {
        this.id = java.util.UUID.randomUUID().toString();
    }  
    
    @Override
    public int hashCode() {
	return id.hashCode();
    }

    @Override
    public boolean equals(Object o) {
        return (o == this || (o instanceof BaseEntity && id.equals(((BaseEntity)o).id)));
    }
    
    @Id
    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}
